#ifndef __RECT__H
#define __RECT__H
#include "types.h"
#include "Point.h"
template <class T> 
class Rect
{
public:
	T Left() { return m_nLeft; }
	T Right() { return m_nRight; }
	T Top() { return m_nTop; }
	T Bottom() { return m_nBottom; }
	T Width() { return m_nRight - m_nLeft + 1; }
	T Height() { return m_nBottom - m_nTop + 1; }
	void SetLeft(T n) { m_nLeft = n; }
	void SetRight(T n) { m_nRight = n; }
	void SetTop(T n) { m_nTop = n; }
	void SetBottom(T n) { m_nBottom = n; }
	
	void SetLeftTopWidthHeight(T nLeft, T nTop, T nWidth, T nHeight) {
		SetLeft(nLeft);
		SetTop(nTop);
		SetRight(nLeft + nWidth - 1);
		SetBottom(nTop + nHeight - 1);
	}
	
	void SetCenterWidthHeight(Point<T> p, T nWidth, T nHeight)
		{ SetLeftTopWidthHeight(p.Col() - nWidth / 2, p.Row() - nHeight / 2, nWidth, nHeight); }
private:
	T m_nLeft, m_nRight, m_nTop, m_nBottom;
};
#endif
